import { useEffect } from "react";

function useInterval(onTick: () => void, delay = 1000) {
  useEffect(() => {
    const id = setInterval(onTick, delay);

    return () => clearInterval(id);
  }, [delay, onTick]);
}

export default useInterval;
